package net.apexes.demo.codegen.ormlite.column;

import net.apexes.commons.ormlite.Column;
import net.apexes.commons.ormlite.ForeignKey;
import net.apexes.commons.ormlite.Index;
import net.apexes.demo.codegen.entity.enums.GoodsCategory;
import net.apexes.demo.codegen.entity.enums.GoodsType;
import net.apexes.demo.codegen.ormlite.column.base.QEntityBase;
import net.apexes.demo.codegen.ormlite.entity.Goods;

/**
 * QGoods is a ORMLite query type for Goods
 * @see Goods
 */
public class QGoods extends QEntityBase<Goods> {

    public static final QGoods $ = new QGoods("GOODS");

    public final Column goodsBaseId = field("goodsBaseId").columnName("GOODS_BASE_ID").varchar(22).notNull().build();

    public final Column goodsType = field("goodsType").columnName("GOODS_TYPE").enumeString(GoodsType.class, 1).notNull().build();

    public final Column goodsCategory = field("goodsCategory").columnName("GOODS_CATEGORY").enumeString(GoodsCategory.class, 1).notNull().build();

    public final Column barCode = field("barCode").columnName("BAR_CODE").varchar(16).build();

    public final Column skuCode = field("skuCode").columnName("SKU_CODE").varchar(22).build();

    public final Column price = field("price").columnName("PRICE").decimal(12, 3).notNull().build();

    public final Column seqOrder = field("seqOrder").columnName("SEQ_ORDER").integer().notNull().build();

    public final Column photo = field("photo").columnName("PHOTO").byteArray().build();

    public final Column templateId = field("templateId").columnName("TEMPLATE_ID").varchar(22).notNull().build();

    public class Indexs {

        public final Index constraintIndex4 = index("CONSTRAINT_INDEX_4").column(goodsBaseId).build();

        public final Index ixGoodsSkuCode = index("IX_GOODS_SKU_CODE").column(skuCode).build();

        public final Index primaryKey4 = index("PRIMARY_KEY_4").unique().column(id).build();

    }

    public final Indexs ix = new Indexs();

    public class ForeignKeys {

        public final ForeignKey constraint40 = foreignKey(goodsBaseId, "GOODS_BASE", "ID");

    }

    public final ForeignKeys fk = new ForeignKeys();

    public QGoods(String tableName) {
        super(Goods.class, tableName);
    }

    @Override
    public Goods newInstance() {
        return new Goods();
    }

    @Override
    public Object getFieldValue(Goods instance, String fieldName) {
        switch (fieldName) {
            case "goodsBaseId":
                return instance.getGoodsBaseId();
            case "goodsType":
                return instance.getGoodsType();
            case "goodsCategory":
                return instance.getGoodsCategory();
            case "barCode":
                return instance.getBarCode();
            case "skuCode":
                return instance.getSkuCode();
            case "price":
                return instance.getPrice();
            case "seqOrder":
                return instance.getSeqOrder();
            case "photo":
                return instance.getPhoto();
            case "templateId":
                return instance.getTemplateId();
            default:
                return super.getFieldValue(instance, fieldName);
        }
    }

    @Override
    public void setupFieldValue(Goods instance, String fieldName, Object value) {
        switch (fieldName) {
            case "goodsBaseId":
                instance.setGoodsBaseId((java.lang.String) value);
                break;
            case "goodsType":
                instance.setGoodsType((net.apexes.demo.codegen.entity.enums.GoodsType) value);
                break;
            case "goodsCategory":
                instance.setGoodsCategory((net.apexes.demo.codegen.entity.enums.GoodsCategory) value);
                break;
            case "barCode":
                instance.setBarCode((java.lang.String) value);
                break;
            case "skuCode":
                instance.setSkuCode((java.lang.String) value);
                break;
            case "price":
                instance.setPrice((java.math.BigDecimal) value);
                break;
            case "seqOrder":
                instance.setSeqOrder((java.lang.Integer) value);
                break;
            case "photo":
                instance.setPhoto((byte[]) value);
                break;
            case "templateId":
                instance.setTemplateId((java.lang.String) value);
                break;
            default:
                super.setupFieldValue(instance, fieldName, value);
                break;
        }
    }

}

